/********************************************************************************
 * Project Name		[JavaSE_Fundamentals]
 * File Name     	[ComparisonOperators.java]
 * Creation Date 	[2015-01-01]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ********************************************************************************/
package basicGrammar.operators;

import java.awt.Component;

import javax.swing.JButton;

/**
 * 比较运算符<br/>
 * 
 * ==, !=, <, <=, >, >=, instanceof<br/>
 * 
 * @author 不落的太阳(Sean Yang aka ShortPeace)
 * @version 1.0
 * @since jdk 1.8
 * 
 */
public class ComparisonOperators {

	/**
	 * 比较运算
	 * 
	 * @param a
	 * @param b
	 */
	public static void ComparisonOperator(int a, int b) {
		System.out.println("a == b " + (a == b));
		System.out.println("a != b " + (a != b));
		System.out.println("a > b " + (a > b));
		System.out.println("a >= b " + (a >= b));
		System.out.println("a < b " + (a < b));
		System.out.println("a <= b " + (a <= b));
	}

	/**
	 * instanceof操作符, 用于在运行期检测对象的所属的类型<br/>
	 * 左操作数为一个对象引用表达式, 通常为一个引用变量或数组元素, 可以取值为null, 返回为false, 不会抛出任何异常<br/>
	 * 右操作数必须为一个类, 接口, 数组, 但不能是java.lang.Class或者代表类名称的字符串对象<br/>
	 */
	public static void ComparisonOperator() {
		JButton[] buttons = new JButton[5];
		System.out.println(buttons instanceof Object); // true
		System.out.println(buttons instanceof Component[]); // true
		System.out.println(buttons instanceof Object[]); // true
	}

	public static void main(String[] args) {
		ComparisonOperator(10, 15);
		ComparisonOperator();
	}
}
